package com.etone.smartAudit.mapstruct;

import com.etone.smartAudit.domain.IapPlatform;
import com.etone.smartAudit.dto.iapPlatform.IapPlatformDTO;
import com.etone.smartAudit.vo.iapPlatform.IapPlatformDetailVO;
import org.mapstruct.*;

/**
 * @author: 蒋学伟
 * @create: 2020-08-27 10:36:59
 * @Description IapPlatformMapstruct
 */

@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface IapPlatformMapstruct {

    @Mappings({
            @Mapping(
                    target = "roleDesc",
                    expression = "java(iapPlatformDTO.getRoleDesc()==null?null:com.alibaba.fastjson.JSON.toJSONString(iapPlatformDTO.getRoleDesc()))"
            ),
            @Mapping(
                    target = "interfaceDesc",
                    expression = "java(iapPlatformDTO.getInterfaceDesc()==null?null:com.alibaba.fastjson.JSON.toJSONString(iapPlatformDTO.getInterfaceDesc()))"
            ),
            @Mapping(
                    target = "accessBill",
                    expression = "java(iapPlatformDTO.getAccessBill()==null?null:com.alibaba.fastjson.JSON.toJSONString(iapPlatformDTO.getAccessBill()))"
            ),
            @Mapping(
                    target = "otherDesc",
                    expression = "java(iapPlatformDTO.getOtherDesc()==null?null:com.alibaba.fastjson.JSON.toJSONString(iapPlatformDTO.getOtherDesc()))"
            )
    })
    void copyToIapPlatform(@MappingTarget IapPlatform iapPlatform, IapPlatformDTO iapPlatformDTO);

    @Mappings({
            @Mapping(
                    target = "roleDesc",
                    expression = "java(org.springframework.util.StringUtils.isEmpty(iapPlatform.getRoleDesc())?null:com.alibaba.fastjson.JSON.parseArray(iapPlatform.getRoleDesc(),com.etone.smartAudit.vo.FileVO.class))"
            ),
            @Mapping(
                    target = "interfaceDesc",
                    expression = "java(org.springframework.util.StringUtils.isEmpty(iapPlatform.getInterfaceDesc())?null:com.alibaba.fastjson.JSON.parseArray(iapPlatform.getInterfaceDesc(),com.etone.smartAudit.vo.FileVO.class))"
            ),
            @Mapping(
                    target = "accessBill",
                    expression = "java(org.springframework.util.StringUtils.isEmpty(iapPlatform.getAccessBill())?null:com.alibaba.fastjson.JSON.parseArray(iapPlatform.getAccessBill(),com.etone.smartAudit.vo.FileVO.class))"
            ),
            @Mapping(
                    target = "otherDesc",
                    expression = "java(org.springframework.util.StringUtils.isEmpty(iapPlatform.getOtherDesc())?null:com.alibaba.fastjson.JSON.parseArray(iapPlatform.getOtherDesc(),com.etone.smartAudit.vo.FileVO.class))"
            )
    })
    IapPlatformDetailVO getIapPlatformDetailVO(IapPlatform iapPlatform);
}
